package database

import (
	"fmt"

	"gorm.io/driver/postgres"
	"gorm.io/gorm"
	"gorm.io/gorm/logger"
)

var dsn = "host=192.168.1.3 port=5432 user=postgres dbname=servey password=docker"
var Connect *gorm.DB

func NewDB(dataSource string) *gorm.DB {
	db,err := gorm.Open(postgres.Open(dsn), &gorm.Config{
		DisableForeignKeyConstraintWhenMigrating: true,
		Logger: logger.Default.LogMode(logger.Info),
	})
	if err != nil {
		panic("连接数据库失败")
	}
	fmt.Println("连接数据库成功")
	return db

}